<?php


namespace app\common\model;

/**
 * 会员模型
 */
class Member extends ModelBase
{
    /**
     * 密码修改器
     */
    public function setPasswordAttr($value)
    {

        return data_md5_key($value);
    }

    //列表
    public function getMemberList($where, $order = "", $limit = "", $field = "*")
    {
        $result = $this->field($field)->where($where)->order($order)->limit($limit)->select();
        if ($result) return $result->toArray();
        return [];
    }

    //单条数据
    public function getMemberInfo($where, $field = '*')
    {
        $result = $this->field($field)->where($where)->find();
        if ($result) return $result->toArray();
        return [];
    }

    //修改
    public function saveMemberData($data, $where)
    {
        return $this->save($data, $where);
    }

    //TODO 只作为示例展示
    public function pageMemberList()
    {
        $page = $this->where([])->paginate(['list_rows' => 10, 'page' => 1]);
        return $page->toArray();
    }
}
